import 'dart:convert' show json;
import 'package:freedom/util/data_type.dart';

List<String>? castList(data) {
  if (data != null) {
    return List.castFrom(data);
  }
  return null;
}

class UserTask {
  UserTask({
    this.userId,
    this.taskArray,
    this.task,
    this.parallel,
    this.dealWith,
    this.removeTag,
  });

  factory UserTask.fromJson(Map<String, dynamic>? jsonRes) {
    if (jsonRes == null) {
      return UserTask();
    }
    return UserTask(
      userId: asT<String>(jsonRes['userId']),
      taskArray: castList(jsonRes['taskArray']),
      task: asT<String>(jsonRes['task']),
      parallel: asT<bool>(jsonRes['parallel']),
      dealWith: asT<bool>(jsonRes['dealWith']),
      removeTag: asT<bool>(jsonRes['removeTag']),
    );
  }

  String? userId;
  List<String>? taskArray;
  String? task;
  bool? parallel;
  bool? dealWith;
  bool? removeTag;

  Map<String, dynamic> toJson() => <String, dynamic>{
        'userId': userId,
        'taskArray': taskArray,
        'task': task,
        'parallel': parallel,
        'dealWith': dealWith,
        'removeTag': removeTag,
      };

  @override
  String toString() {
    return json.encode(this);
  }
}
